﻿// =================================================================== 
// 数据实体层(GDIT.Model)实体映射
//====================================================================
// 文件：Mtb_SceneryPicInfo.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
// 引用DevExpress.Xpo程序集
// 程序集介绍：风貌图片信息实体类
// ===================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace GDIT.Model
{
    public class Mtb_SceneryPicInfo : PersistentClass
    {
        public Mtb_SceneryPicInfo()
            : base()
        {
            this.Modified = false;
        }

        public Mtb_SceneryPicInfo(Session theSession)
            : base(theSession)
        {
            this.Modified = false;
        }

        private string _title = string.Empty;
        /// <summary>
        /// 图片标题
        /// </summary>
        [DbType("varchar(50)")]
        public string Title
        {
            get { return _title; }
            set
            {
                if (_title != value)
                {
                    _title = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _picPath = string.Empty;
        /// <summary>
        /// 图片路径
        /// </summary>
        [DbType("varchar(256)")]
        public string PicPath
        {
            get { return _picPath; }
            set
            {
                if (_picPath != value)
                {
                    _picPath = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 所属图片类型
        /// </summary>
        [Association("PicTypeSceneryPicInfos")]
        public Mtb_PicType PicType;

        private string _alt = string.Empty;
        /// <summary>
        /// 图片提示
        /// </summary>
        [DbType("varchar(256)")]
        public string Alt
        {
            get { return _alt; }
            set
            {
                if (_alt != value)
                {
                    _alt = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 防止编辑后马上保存
        /// </summary>
        protected override void EndEdit()
        {
            return;
        }

        /// <summary>
        /// 检验数据
        /// </summary>
        /// <returns></returns>
        public override string GetDataError()
        {
            if (this._picPath.Trim().Length == 0) { return string.Format("图片路径不能为空"); }
            if (this._title.Trim().Length == 0) { return string.Format("图片标题不能为空"); }
            if (this._picPath.Trim().Length == 0) { return string.Format("图片提示不能为空"); }
            return "";
        }
    }
}
